<?php

namespace catchAdmin\basics\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catcher\CatchAuth;
use catchAdmin\basics\model\BusinessType as BusinessTypeModel;
use catchAdmin\basics\request\BusinessTypeCreateRequest;
class OfficialTags extends CatchController
{

    protected $model;


    public function __construct(\catchAdmin\basics\model\OfficialTags $officialTagsModel)
    {
        $this->model = $officialTagsModel;
    }

    public function index(CatchAuth $auth)
    {
        $user = $auth->user();
        return CatchResponse::paginate($this->model->getList($user['tenant_id']));
    }

    public function create(CatchAuth $auth,Request $request)
    {
        $params = $request->filterEmptyField()->post();
        $user = $auth->user();
        $params['tenant_id'] = $user['tenant_id'];
        return CatchResponse::success($this->model->storeBy($params),"新建成功");
    }

    public function update(Request $request)
    {
        $params = $request->post();
        return CatchResponse::success($this->model->updateBy($params['id'], $params),"编辑成功");
    }

    public function delete(Request $request)
    {
        $id = $request->post('id');
        return CatchResponse::success($this->model->deleteBy($id),'删除成功');
    }
}